package main;

import java.util.ArrayList;
import java.util.List;

import panels.ProgressPanel;
import tree.GameNode;

public class Game implements Cloneable{

	private String game;

	private String absPath;
	private ProgressPanel pro;
	
	private GameNode node;
	
	private List<GameFile> files;
	
	public Game(String game, String absPath, 
			GameNode node, List<GameFile> files){
		this.game = game;
		this.absPath = absPath;
		this.node = node;
		this.pro = null;
		this.setFiles(files);
	}

	public List<GameFile> getFiles() {
		return files;
	}

	public synchronized void setFiles(List<GameFile> files) {
		this.files = files;
	}

	public ProgressPanel getPro() {
		return pro;
	}

	public void setPro(ProgressPanel pro) {
		this.pro = pro;
	}

	public String getGame() {
		return game;
	}

	public String getAbsPath() {
		return absPath;
	}
	
	public GameNode getNode() {
		return node;
	}

	@Override
	protected Game clone() throws CloneNotSupportedException {
		List<GameFile> cloned = cloneFileList();
		return new Game(new String(game), new String(absPath), null, 
				cloned);
	}

	private List<GameFile> cloneFileList() throws CloneNotSupportedException {
		List<GameFile> result = new ArrayList<GameFile>();
		for(int i = 0; i<files.size(); i++){
			result.add(files.get(i).clone());
		}
		return result;
	}

	@Override
	public String toString() {
		return "["+game+","+absPath+"]";
	}

}
